/*
 * @Author: wkh
 * @Date: 2021-11-12 16:22:45
 * @LastEditTime: 2021-11-12 16:22:45
 * @LastEditors: wkh
 * @Description: 
 * @FilePath: /kcp-cpp/include/Trace.hpp
 * 
 */

#ifndef TRACE_HPP_
#define TRACE_HPP_

#include <iostream>
#include <time.h>
#include "util.hpp"

#define TRACE(...) Trace( "[", __FILE__,":",__func__,":",__LINE__,"]", __VA_ARGS__);
//#define TRACE(...) Trace( RED, "[", __FILE__,":",__func__,":",__LINE__,"]",  YELLOW, __VA_ARGS__, WHITE);

//the following are UBUNTU/LINUX ONLY terminal color codes.
#define RESET   "\033[0m"
#define BLACK   "\033[30m"      /* Black */
#define RED     "\033[31m"      /* Red */
#define GREEN   "\033[32m"      /* Green */
#define YELLOW  "\033[33m"      /* Yellow */
#define BLUE    "\033[34m"      /* Blue */
#define MAGENTA "\033[35m"      /* Magenta */
#define CYAN    "\033[36m"      /* Cyan */
#define WHITE   "\033[37m"      /* White */
#define BOLDBLACK   "\033[1m\033[30m"      /* Bold Black */
#define BOLDRED     "\033[1m\033[31m"      /* Bold Red */
#define BOLDGREEN   "\033[1m\033[32m"      /* Bold Green */
#define BOLDYELLOW  "\033[1m\033[33m"      /* Bold Yellow */
#define BOLDBLUE    "\033[1m\033[34m"      /* Bold Blue */
#define BOLDMAGENTA "\033[1m\033[35m"      /* Bold Magenta */
#define BOLDCYAN    "\033[1m\033[36m"      /* Bold Cyan */
#define BOLDWHITE   "\033[1m\033[37m"      /* Bold White */

template<typename T ,typename... Args>
inline void trace(T&& tmp , Args&&... args)
{
    if constexpr(sizeof...(args)  > 0)
    {
        std::cout << tmp << " ";
        trace(std::forward<Args>(args)...);
    }else
    {
        
        std::cout << tmp <<std::endl;
       
    }
}

template<typename T ,typename... Args>
inline void Trace(T&& tmp , Args&&... args)
{
  //time_t curtime;
  //time(&curtime);

  std::cout << BLUE <<"[";
  std::cout << iclock64();
  std::cout << WHITE <<"]";
  //std::cout <<  std::endl;
  //std::cout << ctime(&curtime); 
  trace(std::forward<T>(tmp), std::forward<Args>(args)...);
}



#endif
